﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Ccit.OA.MsQuestion;
using System.Collections.Generic;

namespace Ccit.OA.Question
{
    public partial class qst_statistics_index : Ccit.Utils.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState["Query"] = "";
            }
            InitPage();
        }
        private void InitPage()
        {
            ViewState["Query"] = "";
            if (this.txttName.Text.Trim() != "")
            {
                ViewState["Query"] = " and $$title$$ like'%" + txttName.Text.Replace("'", "''") + "%'";
            }
            if (this.ddlStaue.SelectedValue != "4")
            {
                ViewState["Query"] += " and $$state$$ =" + ddlStaue.SelectedValue + "";
            }
            else
            {
                ViewState["Query"] += " and $$state$$ <>0";
            }
            DataBinde();
        }
        private void DataBinde()
        {
            QuestionBLL Bll = new QuestionBLL();
            List<MsQuestionMes> lstMes = Bll.GetQuestionMesView(ViewState["Query"].ToString());
            dgMain.DataSource = lstMes;
            dgMain.DataBind();
        }

        protected void dgMain_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e)
        {
            if (e.RowType != DevExpress.Web.ASPxGridView.GridViewRowType.Data) return;
            string sRecid = dgMain.GetRowValues(e.VisibleIndex, "id").ToString();
            string state = dgMain.GetRowValues(e.VisibleIndex, "state").ToString();
            string sName = dgMain.GetRowValues(e.VisibleIndex, "title").ToString();
            string stype = dgMain.GetRowValues(e.VisibleIndex, "type").ToString();
            string ucount = dgMain.GetRowValues(e.VisibleIndex, "ucount").ToString();
            /**************************************************************************/
            //e.Row.Cells[0].Text = "<a href=\"javascript:doView('" + sRecid + "')\">" + sName + "</a>";
            e.Row.Cells[6].Text = "<a href=\"javascript:doCount('" + sRecid + "')\">结果统计</a>";  
            /**************************************************************************/
            if (state == "0")
            {
                e.Row.Cells[1].Text = "未发布"; 
            }
            else if (state == "1")
            {
                e.Row.Cells[1].Text = "已发布"; 
            }
            else
            {
                e.Row.Cells[1].Text = "已结束"; 
            }
            if (stype == "1")
            {
                e.Row.Cells[2].Text = "实名";
                e.Row.Cells[3].Text = "<a href=\"javascript:doSelectInfo('" + sRecid + "')\">" + ucount + "</a>";
            }
            else
            { e.Row.Cells[2].Text = "匿名"; }
            /**************************************************************************/
        }

        protected void lnbQuery_Click(object sender, EventArgs e)
        {
            InitPage();
        }
    }
}
